<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Collections" %><%--
  Created by IntelliJ IDEA.
  User: LUMING
  Date: 2024/4/28
  Time: 13:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>简单聊天室</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
            margin: 0;
            padding: 0;
        }
        h1 {
            text-align: center;
            color: #333;
        }
        h3 {
            color: #333;
        }
        ul {
            list-style-type: none;
            padding: 0;
        }
        li {
            margin-bottom: 10px;
            background-color: #fff;
            padding: 5px 10px;
            border-radius: 5px;
            box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
        }
        form {
            margin-top: 20px;
            background-color: #fff;
            padding: 10px;
            border-radius: 5px;
            box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
        }
        input[type="text"], input[type="submit"] {
            padding: 5px;
            margin-bottom: 5px;
            border: 1px solid #ccc;
            border-radius: 3px;
        }
        input[type="submit"] {
            background-color: #007bff;
            color: #fff;
            border: none;
            cursor: pointer;
        }
    </style>
</head>
<body>
<h1>简单聊天室</h1>
<h3>聊天消息</h3>
<ul>
    <%
        List<String> messages = (List<String>) application.getAttribute("messages");
        if (messages != null) {
            for (String msg : messages) {
                out.println("<li>" + msg + "</li>");
            }
        }
    %>
</ul>
<h3>发送消息</h3>
<form action="ChatServlet" method="post">
    用户名: <input type="text" name="username"><br>
    消息: <input type="text" name="message"><br>
    <input type="submit" value="发送">
</form>
</body>
</html>